﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using DOAN.Public;

namespace DOAN.DLL
{
    public class TinhTrangSuDungDAL
    {
        ClsConnection cls;

        public TinhTrangSuDungDAL()
        {
            cls = new ClsConnection();
        }

        public DataTable Load()
        {
            return cls.GetData("TINHTRANGSUDUNG_LOAD");
        }

        public int Insert(TinhTrangSuDungPublic p)
        {
            int Nparameter = 3;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaTinhTrang";
            name[1] = "@TenTinhTrang";
            name[2] = "@TinhTrangSuDung_Id";

            value[0] = p.MaTinhTrang;
            value[1] = p.TenTinhTrang;
            value[2] = p.TinhTrangSuDung_Id;

            return cls.UpdateData("TINHTRANGSUDUNG_INSERT", name, value, Nparameter);
        }

        public int Update(TinhTrangSuDungPublic p)
        {
            int Nparameter = 3;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaTinhTrang";
            name[1] = "@TenTinhTrang";
            name[2] = "@TinhTrangSuDung_Id";

            value[0] = p.MaTinhTrang;
            value[1] = p.TenTinhTrang;
            value[2] = p.TinhTrangSuDung_Id;

            return cls.UpdateData("TINHTRANGSUDUNG_UPDATE", name, value, Nparameter);
        }

        public int Delete(TinhTrangSuDungPublic p)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaTinhTrang";
            value[0] = p.MaTinhTrang;
            return cls.UpdateData("TINHTRANGSUDUNG_DELETE", name, value, Nparameter);
        }
    }
}
